package com.xxg.renrensearch.domain.result;

import lombok.Data;
import org.springframework.data.domain.Page;

import java.util.List;

/**
 * 通用分页结果类型
 *
 * @param <T> 封装类型
 * @author xuxiaogang
 * @date 2021-11-25
 */
@Data
public class PageResult<T> {
    private List<T> content;
    private long totalElements;
    private int totalPages;
    private int currentPageNo;

    public PageResult(Page<T> page) {
        content = page.getContent();
        totalElements = page.getTotalElements();
        totalPages = page.getTotalPages();
        currentPageNo = page.getNumber() + 1;
    }
}
